ImageGear Professional v18 for Mac
Loading an Image
  1. Choose File > Open....

    The key ImageGear call used is IG_load_file(). We use NSOpenPanel dialog to select an image file. All related calls are encapsulated in the mnuFileOpen action in our Sample. Please see NSOpenPanel Class Reference for details.

  2. The image will be displayed.

    Here is the segment of code that demonstrates this operation:

     
    Copy Code

    - (IBAction)mnuFileOpen:(id)sender {
        AT_ERRCOUNT errCount = 0;
        // Create the File Open Dialog class.
        NSOpenPanel* openDlg = [NSOpenPanel openPanel];
       
        // Enable the selection of files in the dialog.
        [openDlg setCanChooseFiles:YES];
       
        // Disable the selection of directories in the dialog.
        [openDlg setCanChooseDirectories:NO];
       
        // Display the dialog.  If the OK button was pressed,
        // process the files.
        if ( [openDlg runModal] == NSOKButton )
        {
            // Get file name as char*
            NSArray* URLs = [openDlg URLs];
            NSURL* URL = [URLs objectAtIndex:0];
            NSString* filePath = [URL path];
            const char* utf8FileName = [filePath UTF8String];
            // Delete an existing hIgear
            if(IG_image_is_valid(hIGear))
                IG_image_delete(hIGear);
           
            errCount = IG_load_file((LPSTR)utf8FileName, &hIGear);
            if(errCount != 0)
                printf("IG_load_file error:\n");

            // Update main view
            [mainScrollViewOutlet setNeedsDisplay:YES];
        }
    }

 

 


©2016. Accusoft Corporation. All Rights Reserved.

Send Feedback